package com.twu.biblioteca.command;

import com.twu.biblioteca.model.Book;
import com.twu.biblioteca.domain.LibraryService;

public class CheckoutBookCommand extends Command {
    LibraryService libraryService;

    public String getBookId() {
        return bookId;
    }

    private String bookId;

    public CheckoutBookCommand(LibraryService libraryService) {
        this.libraryService = libraryService;
    }

    public String execute() {
        Book book = (Book) libraryService.checkOutBook(bookId);
        return MessageFactory.wrapCheckoutBook(book);
    }

    @Override
    public void parameter(String[] args) {
        bookId = args[0];
    }

    @Override
    public boolean hasSubParam() {
        return true;
    }

    @Override
    public String subParamTips() {
        return "Please input book id";
    }
}
